import HmArticle from "@/views/HmArticle.vue";
import HmCollect from "@/views/HmCollect.vue";
//导入HmLike组件
import HmLike from "@/views/HmLike.vue";
//导入HmUser组件
import HmUser from "@/views/HmUser.vue";
//导入HmNotFound组件
import HmNotFound from "@/views/HmNotFound.vue";
//导入HmDetail组件
import HmDetail from "@/views/HmDetail.vue";
//导入HmLayout组件
import HmLayout from "@/views/HmLayout.vue";
//导入HmLogin组件
import HmLogin from "@/views/HmLogin.vue";
//导入HmRegister组件
import HmRegister from "@/views/HmRegister.vue";
//导入HmNewList组件
import HmNewList from "@/views/HmNewList.vue";
//导入HmSuggestList组件
import HmSuggestList from "@/views/HmSuggestList.vue";
//导入vue
import Vue from "vue";
//导入VueRouter
import VueRouter from "vue-router";

//注册
Vue.use(VueRouter);
//创建路由对象
const router = new VueRouter({
  //更改router-link标签类名
  linkActiveClass: "active",
  linkExactActiveClass: "ex-active",
  mode: "history",
  routes: [
    {
      path: "/",
      redirect: "/login",
    },
    {
      path: "/detail",
      component: HmDetail,
    },
    {
      //配置父路由
      path: "/layout",
      component: HmLayout,
      //子路由配置
      children: [
        { path: "/", redirect: "article" },
        {
          path: "article",
          component: HmArticle,
          //配置子路由
          children: [
            { path: "/", redirect: "suggestlist" },
            {
              path: "newlist",
              component: HmNewList,
            },
            {
              path: "suggestlist",
              component: HmSuggestList,
            },
          ],
        },
        {
          path: "collect",
          component: HmCollect,
        },
        {
          path: "like",
          component: HmLike,
        },
        {
          path: "user",
          component: HmUser,
        },
      ],
    },
    //配置登录路由
    {
      path: "/login",
      component: HmLogin,
    },
    //配置注册路由
    {
      path: "/register",
      component: HmRegister,
    },
    {
      path: "*",
      component: HmNotFound,
    },
  ],
});

//导出router
export default router;
